home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sun Solutions 1997 April to September
/
Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso
/
products
/
bin
/
httpd
/
Solaris_2
/
tclsh
< prev
next >
Wrap
Text File
|
1995-12-04
|
12KB
|
428 lines
#!/bin/sh
#
# @(#) .cam,v1.4_wrapper 1.1 Last mod: 17 Oct 1995
#
# Authors: SoftDist Central (softdist@softdist)
#
# Description:
# This is a wrapper for implementing configuration-appropriate command
# execution for CAM
# NOTE : This version has special handling for announce function
#
# Environment:
# CAM_HOME Base directory location
# LD_LIBRARY_PATH
#
##
# Define DIST_HOME
##
# Honor variable UDHOME for transitional support of Engineering environments.
DIST_HOME=${UDHOME:-$DIST_HOME}
DIST_HOME=${DIST_HOME:-/usr/dist}
SAVED_PATH=$PATH
PATH=/bin
##
# Variable Definition Block
##
Environment()
{
if [ -x /bin/uname ];then
export os hostname arch major_os
set `/bin/uname -nrm` 2>&-
hostname=$1
os=$2
arch=`/bin/expr $3 : '\(sun[0-9]*\)' \| $3`
major_os=`/bin/expr $os : '\(.\)'`
return 0
else
return 1
fi
}
export CAM_HOME DIST_HOME SAVE_LD_LIB LD_LIBRARY_PATH NEWS
productname=cam
version=1.4
package=$productname,v$version
# Version_handler ${1+"$@"}
if Environment; then
:
else
[ $_Arch_loaded ] || {
Arch () {
case $1 in
'') /bin/arch $* 2>&- || {
set `/bin/uname -m`
/bin/expr $1 : '\(sun[0-9]*\)' \| $1
}
;;
-k) /bin/arch $* 2>&- || /bin/uname -m ;;
*) if [ -x /bin/arch ]; then
/bin/arch $*
else
set $1 `/bin/uname -m`
[ $1 = `/bin/expr $2 : '\(sun[0-9]*\)' \| $2` ]
fi ;;
esac
}
_Arch_loaded=1
}
[ $_Osr_loaded ] || {
Osr () {
/bin/expr `
{
/bin/uname -r ||
/bin/cat /usr/sys/conf*/RELEASE
} 2>&- ||
/etc/dmesg |
/bin/awk '
BEGIN { status = 1 }
/^SunOS Release/ { print $3; status = 0; exit }
END { exit status }
' ||
/bin/expr "\`
/usr/ucb/strings -50 /vmunix |
/bin/egrep '^SunOS Release'
\`" : 'SunOS Release \([^ ]*\)'
` : '\([.0-9]*\)'
}
_Osr_loaded=1
}
os=`Osr`
arch=`Arch`
hostname=`/bin/hostname 2>&- || /bin/uname -n`
export os hostname arch major_os
fi
#
CAM_HOME=$DIST_HOME/pkgs/$package
command=$CAM_HOME/${major_os}bin.$arch/cam
cmdname=`basename $0`
if [ `/bin/echo $* | /bin/grep -c ",debug" ` -eq 0 ]; then
opt=",silent"
else
opt=
fi
##
# Application Prerequisite Block
##
if [ "$REMHOST" ]; then
REMHOST_S5X=$REMHOST
export REMHOST_S5X
fi
#
# Check Architecture Requirement
#
#
# Check Operating System Version Requirement
#
#
# Check Window System Requirement
#
_ow_display=`/bin/expr "$*" : '.*-display *\([^:]*:[^ ]*\)'`
if [ -z "$OPENWINHOME" -o -z "$DISPLAY" ];then
[ $_Ow_loaded ] || {
# Function:
# @(#)ow (Wayne.Thompson@Sun.COM) 05/15/92
#
# Description:
# This function returns true if invoked from within the OpenWindows
# environment and server permission is true, otherwise false.
# If the following environment variables are NOT set
# they will be set to the default values:
# $DISPLAY
# $LD_LIBRARY_PATH
# $OPENWINHOME
# If they are set, they will NOT be modified.
#
# Variables:
# DIST_HOME Assumes set from wrapper
# OPENWINHOME root of OpenWindows hierarchy.
# LD_LIBRARY_PATH shared libraries directory(s).
# DISPLAY current xnews server/display.
# arch current application architecture.
# owvers OpenWindows version.
# sockets available Xwindow server sockets.
#
# Usage:
# Ow
#
# Return:
# 0 OpenWindows is true, server permission is true.
# 1 OpenWindows is true, server permission is false.
# 2 OpenWindows likely true, $DISPLAY is incorrect.
# $sockets set to /tmp/.X11-unix/X?
# 3 OpenWindows is true, server socket has been removed.
# 4 OpenWindows is false.
#
# Dependencies:
#
# OPENWINHOME fall-thru case is SunOS4.x dependent (ps(1)).
# OPENWINHOME default case is "$DIST_HOME/pkgs/openwin".
#
# Bugs:
# $LD_LIBRARY_PATH set to wrong version of OW not compensated.
##
# Function Load Block
##
Ow () {
export OPENWINHOME
[ $OPENWINHOME ] || {
## OPENWINHOME is not set, set it to something reasonable
[ $_OPENWINHOME ] && __OPENWINHOME=$_OPENWINHOME
if [ ! -x $__OPENWINHOME/bin/xhost ]; then
case $major_os in
4) __OPENWINHOME=$DIST_HOME/share/openwin,v3.0
;;
5) __OPENWINHOME=/usr/openwin
;;
esac
fi
if [ -x $__OPENWINHOME/bin/xhost ]; then
OPENWINHOME=$__OPENWINHOME
else
[ $_DISTENV ] || {
( . $HOME/.dist/.distrc 2>&- ) &&
. $HOME/.dist/.distrc
}
OPENWINHOME=`
/bin/echo $_DISTENV |
/bin/awk '
BEGIN {
FS = "|";
status = 1;
}
{
for (i = 1; i <= NF; i++) {
if ($i == "OpenWin,v3.0") {
print "'$DIST_HOME'/pkgs/openwin,v3.0";
status = 0;
exit;
}
if ($i == "OpenWin,v2.0") {
print "'$DIST_HOME'/'${arch:-\`Arch\`}'/openwin,v2.0";
status = 0;
exit;
}
if ($i ~ /^(SunView|SunDesk|DeskSet)/) {
print "SunView";
status = 0;
exit;
}
}
}
END { exit status }
' ||
/bin/ps ewwtco 2>&- |
/bin/awk '
BEGIN { status = 1 }
/OPENWINHOME/ {
for (i = 6; i <= NF; i++) {
split($i, x, "=");
if (x[1] == "OPENWINHOME") {
print x[2];
status = 0;
exit;
}
}
}
END { exit status }
' || {
[ -x /opt/openwin/bin/xhost ] &&
/bin/echo /opt/openwin
} ||
if [ -x /usr/openwin/bin/xhost ]; then
/bin/echo /usr/openwin
else
/bin/echo $DIST_HOME/pkgs/openwin
fi
`
fi
}
[ ${DISPLAY:=$_ow_display} ] || {
## DISPLAY is not set, set it to something reasonable
_=`
_=\`/bin/expr "\\\`/bin/who am i 2>&-\\\`" : '.*(\([^.)]*\.*[^.)]*\)'\`
{
NIS_PATH=${NIS_PATH:-org_dir.\$:\$} \
/bin/nismatch $_ hosts 2>&- ||
/bin/ypmatch $_ hosts 2>&-
} |
/bin/awk '{ print $2; exit }'
`
if [ $_ ]; then
DISPLAY=$_:0
export DISPLAY
#else
# DISPLAY=:0.0
fi
}
}
_Ow_loaded=1
}
Ow
fi
# check if arch is i86pc
if [ "$arch" = "i86pc" -a -z "`/bin/grep $cmdname $DIST_HOME/exe/i86pc 2>/dev/null`" -o "$arch" = "prep" ]; then
Remhost()
{
export OPENWINHOME DISPLAY LD_LIBRARY_PATH REMOTE
if [ "$major_os" = "4" ]; then
RSH=/usr/ucb/rsh
else
RSH=/bin/rsh
fi
cmdname=`/bin/basename $0`
if [ "$REMHOST" ]; then
whoami=`who am i|/bin/awk '{print $1}'`
if $RSH -n $REMHOST "/bin/grep root /etc/passwd" >/dev/null 2>&1
then
# Even if DISPLAY isn't set, try to do something reasonable
display_num=`/bin/echo $DISPLAY|/bin/awk -F: '{print $2}'`
display_num=${display_num:-0.0}
display_num=":${display_num}"
display_host=`/bin/echo $DISPLAY|/bin/awk -F: '{print $1}'`
[ "$display_host" = "unix" ] && display_host=
display_host=${display_host:-$hostname}
OPENWINHOME=/usr/openwin; export OPENWINHOME
${OPENWINHOME}/bin/xhost -display $display_host +$REMHOST >/dev/null 2>&1
/bin/echo >&2 "Adding host $REMHOST to access list"
/bin/echo >&2 "Remotely executing $cmdname on host ${REMHOST}"
REMPATH=`/bin/echo ${PATH} | /bin/sed -e "s:${DIST_HOME}:/usr/dist:g"`
REMCOMMAND="${REMCOMMAND} `/bin/echo $0 |
/bin/sed -e \"s:${DIST_HOME}:/usr/dist:g\"`"
REMCOMMAND=/usr/dist/exe/$cmdname
# If REMWINDOW is "y", then we either have an app that expects the user
# to be able to type at it once it's invoked (CONCEPT!), or we have
# an app like FOCUS, which makes bad assumptions about its environment.
if [ "$REMWINDOW" = y ]; then
/bin/echo "DISPLAY=$display_host$display_num
TERM=$TERM
PATH=$REMPATH
DIST_HOME=\${DIST_HOME:-/usr/dist}
export DIST_HOME
WRAPPER_FUNCTIONS=\${WRAPPER_FUNCTIONS:-\$DIST_HOME/pkgs/wrapper_funcs/sh}
export WRAPPER_FUNCTIONS
. \$WRAPPER_FUNCTIONS/ow.sh.fctn
Ow
REMOTE=yes
export PATH DISPLAY OPENWINHOME LD_LIBRARY_PATH TERM REMOTE
$REMSPECIAL
\$OPENWINHOME/bin/cmdtool -i $REMCOMMAND ${1+$@}
read abc" | \
exec $RSH $REMHOST sh
else
/bin/echo "DISPLAY=$display_host$display_num
TERM=$TERM
PATH=$REMPATH
REMOTE=yes
export PATH DISPLAY OPENWINHOME LD_LIBRARY_PATH TERM REMOTE
$REMSPECIAL
$REMCOMMAND ${1+$@}" | exec $RSH $REMHOST sh
fi
exit
else
/bin/echo "
$whoami is not able to log directly into $REMHOST. This may be
because: $REMHOST is down, $REMHOST does not have an account for
$whoami, or $REMHOST's /etc/hosts.equiv file does not permit
direct logins from $hostname.
Please try later or set REMHOST to a remote server that is
accessible.
"
exit
fi
elif [ -z "$REMHOST" ]; then
/bin/echo "
A Solaris 2.x version of $cmdname is not yet available on x86
machines.
To display $cmdname on $hostname, it is recommended that you use
the following procedure:
1. Set an environmental variable \"REMHOST\" to the name of a known
xhost server. For example:
setenv REMHOST <some_xhost_server> (csh users)
or
REMHOST=<some_xhost_server>; export REMHOST (sh users)
or
export REMHOST=<some_xhost_server> (ksh users)
You must be able to log directly into the machine
you have REMHOST set to. In addition The machine
must have $DIST_HOME and in some cases, your home
directory mounted.
Please do not set REMHOST to a $DIST_HOME server!!!
2. After setting REMHOST, execute the $cmdname command.
This procedure only works for OpenWindows based tools.
It will not work for SunView based tools.
Thank-you for your cooperation
" | more
exit
fi
}
Remhost "$@"
fi
##
SAVE_LD_LIB=${LD_LIBRARY_PATH:-}
LD_LIBRARY_PATH=${OPENWINHOME}/lib:$CAM_HOME/${major_os}lib.${arch}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
NEWS=
if [ $major_os = "5" ]; then
if [ `/bin/expr $os \< "5.3"` -eq 1 ] ; then
NEWS=".news"
fi
fi
##
# Local Configuration Block
##
##
# Application Execution Block
##
PATH=$SAVED_PATH; export PATH
exec $command $cmdname ${1+"$@"} $opt